import {Component} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import { RouterModule } from '@angular/router';
import {Hero} from '../hero';
import {HeroService} from '../hero.service';


@Component({
  selector: 'app-dashboard',
  imports: [CommonModule, FormsModule,RouterModule],
  templateUrl: './dashboard.component.html',
  styleUrl: './dashboard.component.css'
})
export class DashboardComponent {

  heroes: Hero[] = [{id:1,name:"hello"}];

  constructor(private heroService: HeroService) {
  }

  ngOnInit() {
    this.getHeroes();
  }

  getHeroes(): void {
    this.heroService.getHeroes()
      .subscribe(remoteHeroes => this.heroes = remoteHeroes);
  }
}
